<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>
        导入项目Excel
    </title>

    <link rel="stylesheet" href="${ctx}/static/inspinia/js/plugins/fileinput/css/fileinput.css">
</head>

<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i><a>导入项目Excel</a>
                    </li>
                    <li class="active">
                        <strong>
                            导入项目Excel
                        </strong>
                    </li>
                </ol>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                                <h3>导入Excel</h3>
                                <form id="uploadimg-form" enctype="multipart/form-data"  action="${ctx}/admin/ehm/user/excelread" method="post">
                                    <input type="file" title="选择文件" name="file" id="fileUpload"/><br /><br />
                                    <input id="fileBtn" type="submit" class="btn" value="文件上传"/><br /><br />
                                </form>

                                <div id="showData" style="display: none;">
                                    <div>
                                        <p>导入数据如下：</p>
                                        <p id="jsonShow"></p>
                                    </div>
                                </div>
                            </div>
                         </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${ctx}/static/js/jquery.form.js"></script>
<script src="${ctx}/static/inspinia/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctx}/static/inspinia/js/bootstrap.min.js"></script>
<script src="${ctx}/static/inspinia/js/plugins/fileinput/fileinput.min.js"></script>
<script src="${ctx}/static/inspinia/js/plugins/fileinput/fileinput_locale_zh.js"></script>
<script>
    $(function() {
        $("#uploadimg-form").resetForm().validate({
            rules: {
                "fileUpload": {
                    required: true,
                    accept: "xls"
                }
            },
            messages: {
                "fileUpload": {
                    required: "请选择上传文件",
                    accept: "文件格式不支持，请上传 xls 格式的文件"
                }
            },
            submitHandler: function() {
                $("#uploadimg-form").ajaxSubmit({
                    success: function(data){
                        console.log(data)
                       var result = $.parseJSON(data.replace(/<.*?>/ig,""));
                        var msg = result.msg;
                        if(null!=msg && msg!=undefined && msg != "0"){
                            parent.layer.msg(msg);
                        }
                        var iframeId = parent.$("#pages_tabs li.active").find("a").attr("href");
                        parent.$(iframeId).find("iframe")[0].contentWindow.query();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },
                    error: function() {
                        parent.layer.msg('导入错误');
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                });
                return false;
            }
        });
    });
</script>
</body>

</html>
